package messy.observer;

import java.util.ArrayList;
import java.util.List;

/**
 * 模拟执行操作
 * @author admin
 *
 */
public class TestAction {

	List<Observer> observerList = new ArrayList<Observer>();

	public void addServer(Observer observer) {
		observerList.add(observer);
	}

	public void notifyObserver() {
		for (Observer observer : observerList) {
			observer.observerOption();
		}
	}

	public void testOption1() {
		System.out.println("模拟方法1执行了!");
		notifyObserver();
	}

	public void testOption2() {
		System.out.println("模拟方法2执行了!");
		notifyObserver();
	}

	public static void main(String[] args) {
		TestAction action = new TestAction();
		action.addServer(new MyObserver("张三"));
		action.addServer(new MyObserver("李四"));

		action.testOption1();

		action.testOption2();

	}
}
